# -*- coding: utf-8 -*-
import md5
from django.utils import simplejson

def md5_encode(str):
    """
    summary:
        MD5 encode
    author:
        李华顺<huacnlee@gmail.com>
    """
    return md5.new(str).hexdigest()

def obj2dict(obj):
    """
    summary:
        将object转换成dict类型
    """
    memberlist = [m for m in dir(obj)]
    _dict = {}
    for m in memberlist:
        if not callable(m):
            if m[0] != "_":
                if type(m) in [type(True),type(""),type(0)]:
                        _dict[m] = getattr(obj,m)

    return _dict